var Amqp = require('../api/amqp').Amqp;
/**
 * Methods for protocol tunneling.
 *
 * The tunnel methods are used to send blocks of binary data - which can be serialised AMQP methods
 * or other protocol frames - between AMQP peers.
 *
 * @class
 * @extends events.EventEmitter
 * @exports Tunnel as impl.Tunnel
 * @param handler
 */
function Tunnel(/**handlers.Connection*/handler){
    this.handler = handler;
}
require('sys').inherits(Tunnel, require('events').EventEmitter);
/**
 * Sends a tunnelled method.
 *
 * This method tunnels a block of binary data, which can be an encoded AMQP method or other data.
 * The binary data is sent as the content for the Tunnel. Request method.
 *
 * @param {Object} args
 * @param {Object} args.metaData This field table holds arbitrary meta-data that the sender needs
 *      to pass to the recipient.
 * @param {Object} fields
 * @param {Number} fields.broadcast The message broadcast mode.
 * @param {String} fields.dataName The name or type of the message being tunnelled.
 * @param {Number} fields.durable The message durability indicator.
 * @param {Object} fields.headers Message header field table.
 * @param {String} fields.proxyName The identity of the tunnelling proxy.
 * @param {String} body
 */
Tunnel.prototype.request = function(args, fields, body){
    this.handler.call(Amqp.Class.Tunnel, Amqp.Class.Tunnel.Request, args, fields, body);
};
exports.Tunnel = Tunnel;
